import React,{ Component } from 'react'

class Life extends Component {
	constructor() {
        super()
        this.state = {
            count:1
        }
    }
    componentWillReceiveProps(){
        console.log('componentWillReceiveProps')
    }
	componentWillMount() {
		console.log('组件将要挂载')
	}
	componentDidMount() {
		console.log('组件挂载完成')
    }
    shouldComponentUpdate(){
        console.log('组件数据更新吗?')
        return true
    }
    componentWillUpdate(){
        console.log('组件数据跟新');
    }
    add(){
        this.state.count += 1
        this.setState({
			count: this.state.count
		})
    }
	render() {
		console.log('组件将要挂载,渲染中')
		return (
            <div>
                数字:{ this.state.count }
                <button onClick={ this.add.bind(this) }>加一</button>
            </div>
        )
	}
}

export default Life